[filename, pathname] = uigetfile('*.txt');  % 默认显示所有文件

fullname = fullfile(pathname, filename);

if isequal(filename, 0)
    disp('用户取消了文件选择。');
else
    disp(['用户选择了文件：', fullname]);
end

% 读取数据（自动按空格分割）
data = importdata(fullname, ' ');

%x = data(:, 1);
%y = data(:, 2);

x = data(:, 2);
y = data(:, 3);

vx = [zeros(1,1); diff(x)];
ax = [zeros(1,1); diff(vx)];
jx = [zeros(1,1); diff(ax)];

vy = [zeros(1,1); diff(y)];
ay = [zeros(1,1); diff(vy)];
jy = [zeros(1,1); diff(ay)];

v = sqrt(vx.^2 + vy.^2);
a = sqrt(ax.^2 + ay.^2);
j = sqrt(jx.^2 + jy.^2);

% 绘制三维散点图
figure("Name", [filename, ' - 轨迹图']);  % 创建一个新的图形窗口
scatter(x, y, 'filled');  % 绘制二维散点图
xlabel('X');  % X 轴标签
ylabel('Y');  % Y 轴标签
title('轨迹图');  % 图形标题
grid on;  % 开启网格

timefrepplot([filename, ' - 合数据'], '合', v, a, j);

timefrepplot([filename, ' - X数据'], 'X', vx, ax, jx);

timefrepplot([filename, ' - Y数据'], 'Y', vy, ay, jy);